package com.sel.modelo;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public abstract class SenhaMd5 
{
    public static String hashSenha(String senha)
    {
        String hash = senha;
        try 
        {
            // Create MD5 Hash
            MessageDigest digito = java.security.MessageDigest.getInstance("MD5");
            digito.update(hash.getBytes());
            byte messageDigest[] = digito.digest();

            // Create Hex String
            StringBuffer retornoHash = new StringBuffer();
            for (int i = 0; i < messageDigest.length; i++)
            {
                retornoHash.append(Integer.toHexString(0xFF & messageDigest[i]));
            }
            return retornoHash.toString();
        } 
        catch (NoSuchAlgorithmException e) 
        {
            e.printStackTrace();
        }
        return "";
    }
}
